﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace GatherWebLib
{
    /// <summary>
    /// 采集任务类别
    /// </summary>
    public class cTaskClass
    {
        cXmlIO xmlConfig;
        DataView TaskClass;
        public cTaskClass()
        {
            try
            {
                xmlConfig = new cXmlIO(cXmlSConfig.TaskPath + "TaskClass.xml");

                //获取TaskClass节点
                TaskClass = xmlConfig.GetData("descendant::TaskClasses");
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }

        ~cTaskClass()
        {
            xmlConfig = null;
        }

        //根据指定的Task分类名称返回任务分类所存储的路径
        public string GetTaskClassPathByName(String Name)
        {
            int i = 0;
            for (i = 0; i < GetTaskClassCount(); i++)
            {
                if (TaskClass[i].Row["Name"].ToString() == Name)
                {
                    string tClassPath = cXmlSConfig.TaskPath + TaskClass[i].Row["Path"].ToString();
                    return tClassPath;

                }
            }
            return "";
        }
        //计算当前共有多少个TaskClass
        public int GetTaskClassCount()
        {
            int tCount = 0;

            if (TaskClass == null)
                tCount = 0;
            else
                tCount = TaskClass.Count;
            return tCount;
        }
    }
}
